package com.haofengsoft.scce.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import com.haofengsoft.scce.db.dao.AdvertInfoDao;
import com.haofengsoft.scce.db.dao.CollectingOperLogDao;
import com.haofengsoft.scce.db.dao.MarketOverViewDao;
import com.haofengsoft.scce.db.dao.StoneGoldDao;
import com.haofengsoft.scce.db.dao.consultation.AttentionItemDao;
import com.haofengsoft.scce.db.dao.consultation.BeiJingDao;
import com.haofengsoft.scce.db.dao.consultation.DailyLimitBoardDao;
import com.haofengsoft.scce.db.dao.consultation.FocusNewDao;
import com.haofengsoft.scce.db.dao.consultation.GuestColumnDao;
import com.haofengsoft.scce.db.dao.consultation.NanJingDao;
import com.haofengsoft.scce.db.dao.consultation.OptionalStampDao;
import com.haofengsoft.scce.db.dao.consultation.ShangHaiDao;
import com.haofengsoft.scce.db.dao.consultation.ZhongNanDao;

import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * Master of DAO (schema version 1000): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 101;

    /**
     * Creates underlying database table using DAOs.
     */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        AdvertInfoDao.createTable(db, ifNotExists);
        AttentionItemDao.createTable(db, ifNotExists);
        FocusNewDao.createTable(db, ifNotExists);
        NanJingDao.createTable(db, ifNotExists);
        BeiJingDao.createTable(db, ifNotExists);
        ShangHaiDao.createTable(db, ifNotExists);
        ZhongNanDao.createTable(db, ifNotExists);
        DailyLimitBoardDao.createTable(db, ifNotExists);
        GuestColumnDao.createTable(db, ifNotExists);
        MarketOverViewDao.createTable(db, ifNotExists);
        OptionalStampDao.createTable(db, ifNotExists);
        StoneGoldDao.createTable(db, ifNotExists);
        CollectingOperLogDao.createTable(db, ifNotExists);
    }

    /**
     * Drops underlying database table using DAOs.
     */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        AdvertInfoDao.dropTable(db, ifExists);
        AttentionItemDao.dropTable(db, ifExists);
        FocusNewDao.dropTable(db, ifExists);
        NanJingDao.dropTable(db, ifExists);
        BeiJingDao.dropTable(db, ifExists);
        ShangHaiDao.dropTable(db, ifExists);
        ZhongNanDao.dropTable(db, ifExists);
        DailyLimitBoardDao.dropTable(db, ifExists);
        GuestColumnDao.dropTable(db, ifExists);
        MarketOverViewDao.dropTable(db, ifExists);
        OptionalStampDao.dropTable(db, ifExists);
        StoneGoldDao.dropTable(db, ifExists);
        CollectingOperLogDao.dropTable(db, ifExists);
    }

    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion
                    + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(AdvertInfoDao.class);
        registerDaoClass(AttentionItemDao.class);
        registerDaoClass(FocusNewDao.class);
        registerDaoClass(NanJingDao.class);
        registerDaoClass(BeiJingDao.class);
        registerDaoClass(ShangHaiDao.class);
        registerDaoClass(ZhongNanDao.class);
        registerDaoClass(DailyLimitBoardDao.class);
        registerDaoClass(GuestColumnDao.class);
        registerDaoClass(MarketOverViewDao.class);
        registerDaoClass(OptionalStampDao.class);
        registerDaoClass(StoneGoldDao.class);
        registerDaoClass(CollectingOperLogDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

}
